﻿@using Huirui.Cavan.Domain.MainBoundedContext.StockModule
@model Huirui.Cavan.Presentation.ViewModel.StockModule.IStockInOutViewModel
@{
    Layout = null;
}
@using (Html.BeginForm(ActionConst.SEARCH, ControllerConst.STOCKINOUT, FormMethod.Post))
{
    <div class="tool_bar">
        <input id="stockinout_query" type="submit" style="display: none;" />
        <input id="stockinout_reset" type="reset" style="display: none" />
        <a href="#" class="easyui-linkbutton" data-options="plain:true,iconCls:'icon-undo'" onclick="javascript:$('#stockinout_reset').click()">重置</a>
        <a href="#" class="easyui-linkbutton" data-options="plain:true,iconCls:'icon-search'" onclick="javascript:$('#stockinout_query').click()">查询</a>
        <a href="#" class="easyui-linkbutton" data-options="plain:true,iconCls:'icon-print'">打印</a>
        <a href="#" class="easyui-linkbutton" data-options="plain:true,iconCls:'icon-collapse'" onclick="toggleHeard()">折叠/展开</a>
    </div>
    <table class="form_heard">
        <tr>
            <td class="c100">
                <label>
                    日期:</label>
            </td>
            <td class="c160">
                @Html.TextBoxFor(m => m.SearchParam.StartDate, new { id = "stockInOutDateStart", @class = "Wdate", @type = "text", @onfocus = "WdatePicker({wdate:true,isShowClear:false,readOnly:true,skin:'whyGreen',maxDate:'%y-%M-%d'})" })
            </td>
            <td class="c30">
                <label>
                    至</label>
            </td>
            <td class="c160">
                @Html.TextBoxFor(m => m.SearchParam.EndDate, new { id = "stockInOutDateEnd", @class = "Wdate", @type = "text", @onfocus = "WdatePicker({wdate:true,isShowClear:false,readOnly:true,skin:'whyGreen',maxDate:'%y-%M-%d'})" })
            </td>
        </tr>
        <tr>
            <td class="c100">
                <label>供应商:</label>
            </td>
            <td class="c160">
                @Html.TextBox("supplierNameForStockInOut","", new { id = "supplierNameForStockInOut" })
                @Html.HiddenFor(m => m.SearchParam.SupplierCode,  new { id = "supplierCodeForStockInOut" })
            </td>
            <td class="c100">
                <label>入库编号:</label>
            </td>
            <td class="c160">
                @Html.TextBoxFor(m => m.SearchParam.ID,  new { id = "idForStockInOut" })
            </td>
        </tr>
    </table>
    <table id="stockinoutlist_gd" class="easyui-datagrid" toolbar="#stockinoutlist_tb" title="入库列表">
        <thead>
            <tr>
                <th data-options="field:'ck',checkbox:'true',width:10"></th>
                <th data-options="field:'Id',width:80">入库编码</th>
                <th data-options="field:'InOutDate',width:80">日期</th>
                <th data-options="field:'SupplierName',width:80">供应商</th>
                <th data-options="field:'Currency',width:80">币别</th>
                <th data-options="field:'CurrencyRate',width:80">汇率</th>
                <th data-options="field:'Amount',width:80">金额</th>
                <th data-options="field:'EmployeeName',width:80">采购人员</th>
                <th data-options="field:'Producer',width:80">制单员</th>
                <th data-options="field:'Remark',width:80">备注</th>
            </tr>
        </thead>
    </table>
    <div id="stockinoutlist_tb">
        <a href="#" class="easyui-linkbutton" iconcls="icon-print" plain="true" onclick="javascript:alert('打印列表')">打印列表</a>
        <a href="#" class="easyui-linkbutton" iconcls="icon-excel" plain="true" onclick="javascript:alert('引出')">引出</a>
    </div>
}
<script type="text/javascript">
    $(function () {
        $("form[action^='/stockinout/search']").submit(function () {
            $.ajax({
                url: this.action,
                type: this.method,
                data: $(this).serialize(),
                success: function (result) {
                    if (result.total > 0) {
                        $('#stockinoutlist_gd').datagrid({
                            idfield: 'Id',
                            singleSelect: 'true',
                            selectOnCheck: 'true',
                            fitColumns: 'true',
                            pagination: 'true',
                            data: result
                        });
                    }
                    else {
                        $('#stockinoutlist_gd').datagrid('loadData', { total: 0, rows: [] });
                    }
                },
                error: function () {
                    alert('系统繁忙，请稍候再试');
                }
            })

            return false;
        });
    });
</script>
